package com.lc202407;

public class Solution415 {
    public String addStrings(String num1, String num2) {
        int n = num1.length();
        int m = num2.length();
        int total = 0;
        String res = "";
        int max = Math.max(n, m);
        for (int i = 0; i < max; i++) {
            if (i < n) {
                total += num1.charAt(n - i - 1) - '0';
            }
            if (i < m) {
                total += num2.charAt(m - i - 1) - '0';
            }
            res = (total % 10) + res;
            total = total / 10;
        }
        if (total != 0) {
            res = total + res;
        }
        return res;
    }
}
